{% extends 'base.html' %}
{% load i18n %}
{% load crispy_forms_tags %} {# Load crispy tags #}

{% block title %}{{ view_title }} - {{ block.super }}{% endblock %}

{% block content %}
<h1>{{ view_title }}</h1>

<div class="card shadow-sm">
    <div class="card-body">
        <form method="post" novalidate> {# novalidate prevents browser validation #}
            {% csrf_token %}
            {{ form|crispy }} {# Render form using crispy #}

            <div class="mt-4">
                <button type="submit" class="btn btn-primary"><i class="bi bi-check-circle"></i> {% trans "保存" %}</button>
                {% if object %} {# Show cancel link pointing to detail view if editing #}
                    <a href="{{ object.get_absolute_url }}" class="btn btn-secondary"><i class="bi bi-x-circle"></i> {% trans "取消" %}</a>
                {% else %} {# Show cancel link pointing to list view if adding #}
                    <a href="{% url 'field_management:field_list' %}" class="btn btn-secondary"><i class="bi bi-x-circle"></i> {% trans "取消" %}</a>
                {% endif %}
            </div>
        </form>
    </div>
</div>
{% endblock %}